home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17688 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.2 KB  |  65 lines

  1. Newsgroups: comp.lang.java,comp.lang.c++,comp.lang.smalltalk
  2. Path: undergrad.math.uwaterloo.ca!clgonsal
  3. From: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves)
  4. Subject: Re: Will Java kill C++?
  5. Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
  6. Message-ID: <Dpz6It.2An@undergrad.math.uwaterloo.ca>
  7. Date: Tue, 16 Apr 1996 22:01:41 GMT
  8. References: <3134D499.653E@ix.netcom.com> <4kbfn8$1bu@news1.is.net> <4kqjf6$kh0@kaiwan009.kaiwan.com> <317173F1.5790@concentric.net>
  9. Nntp-Posting-Host: lhopital.uwaterloo.ca
  10. Organization: University of Waterloo
  11.  
  12. In article <317173F1.5790@concentric.net>,
  13. Alan L. Lovejoy <alovejoy@concentric.net> wrote:
  14. >Mike Zorn wrote:
  15. >> 
  16. >> In <4kbfn8$1bu@news1.is.net> mvantassel@teambca.com (Mark VanTassel) writes:
  17. >> 
  18. >> >"Alan L. Lovejoy" <alovejoy@concentric.net> wrote:
  19. >> >>Bzzzt!  Not according to the benchmarks I've done.  Go benchmark the factorial or fibonacci
  20. >> >>functions (implemented recursively) in both C and a good Smalltalk.  You are in for a big
  21. >> >>surprise.
  22. >
  23. >> >I don't think this is a valid benchmark... (and I too fail to see how
  24. >> >Smalltalk can be faster than C++ except perhaps in bizarre special
  25. >> >cases)
  26. >>    True, the Fibonacci and factorial are not good candidates for a
  27. >> recursive algorithm.  (They're just taught that way because it's one
  28. >> of the few recursive problems that we can understand in first-year
  29. >> college courses.)
  30. >>    On the other hand, almost any interesting program, compiled & run
  31. >> in different languages, should be able to give a good idea of how the
  32. >> languages compare.  For my part, I'd also like to look at the source
  33. >> code, and know how long it took to write (and debug) the two programs.
  34. >>    So, Alan, I guess you'll have to come up with a program for
  35. >> Ackermann's Function in C++ and Smalltalk to satisfy the rest of us.
  36. >> 
  37. >> Mike Zorn      ozma@kaiwan.com   |  Thought for the day:
  38. >>   http://www.kaiwan.com/~ozma/   |    Java is C--
  39. >
  40. >I did those benchmars to prove that Smalltalk message sends are faster
  41. >than c function calls.  To do that, I needed a benchmark that consisted
  42. >mostly of function calls/message sends--and involved as little other
  43. >code as possible.  The recursive factorial and fibonacci functions
  44. >meet those requirements better than anything else I could think of.
  45.  
  46. Both factorial and fibonacci are tail-recursive, which means that your
  47. translator may be doing tail recursion elimination, folding your n message
  48. sends (or function calls) down to one (plus a loop). 
  49.  
  50. I don't know of any C compilers that do tail recursion elimination. I
  51. don't know enough about the workings of Smalltalk to say for sure, but it
  52. may be possible that your translator is doing tail recursion elimination,
  53. thereby making message sends seem to be a heck of a lot more efficient
  54. than they really are.
  55.  
  56. Try doing a similar test with functions that aren't tail-recursive. Or at
  57. least find out if your Smalltalk translator may be doing tail-recursion
  58. elimination.
  59.  
  60. -- 
  61.         Carl Laurence Gonsalves - clgonsal@undergrad.math.uwaterloo.ca
  62.                    Computer Science, University of Waterloo
  63.                http://www.undergrad.math.uwaterloo.ca/~clgonsal/
  64.                    http://www.csclub.uwaterloo.ca/~clgonsal/
  65.